#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int N=5e5+5;
int n;
set<ll> S;

ll calc(){
  ll lst=-1,res=0,sl=0,sr=0;
  for(auto i=S.begin(),j=prev(S.end());i!=S.end();i=next(i),j=prev(j)){
  	sl+=*i,sr+=*j;
  	res+=max(sr-max(lst,sl),0ll);
  	lst=max(lst,sr);
  }
  return res;
}

int main(){
  freopen("kte.in","r",stdin);
  freopen("kte.out","w",stdout);
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n;
  while(n--){
  	ll x;cin>>x;
  	if(S.find(x)!=S.end()) S.erase(x);
  	else S.insert(x);
    cout<<calc()<<'\n';
  }
  return 0;
}
